import PaletteProvider from 'bpmn-js/lib/features/palette/PaletteProvider';

import ElementFactory from 'bpmn-js/lib/features/modeling/ElementFactory.js';
import { assign } from 'min-dash';
import { createAction } from '../utils';

class RewritePaletteProvider extends PaletteProvider {
  private readonly _palette: PaletteProvider;
  private readonly _create: any;
  private readonly _elementFactory: ElementFactory;
  private readonly _spaceTool: any;
  private readonly _lassoTool: any;
  private readonly _handTool: any;
  private readonly _globalConnect: any;
  private readonly _translate: any;
  private readonly _moddle: any;
  constructor(palette, create, elementFactory, spaceTool, lassoTool, handTool, globalConnect) {
    super(palette, create, elementFactory, spaceTool, lassoTool, handTool, globalConnect, 2000);
    this._palette = palette;
    this._create = create;
    this._elementFactory = elementFactory;
    this._spaceTool = spaceTool;
    this._lassoTool = lassoTool;
    this._handTool = handTool;
    this._globalConnect = globalConnect;
  }
  getPaletteEntries() {
    const actions = {},
      create = this._create,
      elementFactory = this._elementFactory,
      lassoTool = this._lassoTool,
      handTool = this._handTool,
      spaceTool = this._spaceTool,
      globalConnect = this._globalConnect;

    assign(actions, {
      'hand-tool': {
        group: 'tools',
        className: 'hlxb-icon-hand-tool',
        title: '手型工具',
        action: {
          click: function (event) {
            handTool.activateHand(event);
          },
        },
      },
      'lasso-tool': {
        group: 'tools',
        className: 'hlxb-icon-lasso-tool',
        title: '套索工具',
        action: {
          click: function (event) {
            lassoTool.activateSelection(event);
          },
        },
      },
      'space-tool': {
        group: 'tools',
        className: 'hlxb-icon-space-tool',
        title: '激活创建/删除空间工具',
        action: {
          click: function (event) {
            spaceTool.activateSelection(event);
          },
        },
      },
      'global-connect-tool': {
        group: 'tools',
        className: 'hlxb-icon-connection-multi',
        title: '全局连线',
        action: {
          click: function (event) {
            globalConnect.toggle(event);
          },
        },
      },
      'tool-separator': {
        group: 'tools',
        separator: true,
      },
      'create.start-event': createAction(
        elementFactory,
        create,
        'bpmn:StartEvent',
        'events',
        'hlxb-icon-start-event',
        '开始事件',
      ),

      'create.user-task': createAction(
        elementFactory,
        create,
        'bpmn:UserTask',
        'events',
        'hlxb-icon-user-task',
        '用户任务',
      ),
      'create.exclusive-gateway': createAction(
        elementFactory,
        create,
        'bpmn:ExclusiveGateway',
        'events',
        'hlxb-icon-gateway',
        '判断',
      ),
      'create.end-event': createAction(
        elementFactory,
        create,
        'bpmn:EndEvent',
        'events',
        'hlxb-icon-end-event',
        '结束事件',
      ),
      // 'gateway-separator': {
      //   group: 'gateway',
      //   separator: true,
      // },
    });

    return actions;
  }
}

RewritePaletteProvider.$inject = [
  'palette',
  'create',
  'elementFactory',
  'spaceTool',
  'lassoTool',
  'handTool',
  'globalConnect',
  'translate',
];

export default RewritePaletteProvider;
